<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <script type="text/javascript">
      function Person(name, age, sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
      }
      Person.prototype.sayHi = function () {
        console.log('hello I am  ' + this.name);
      }
      function Student(name, age, sex, score) {
        this.score = score;
        Person.call(this, name, age, sex);
      }
      // 改变指向,需要不同的名字年龄和性别所以不用传参
      Student.prototype = new Person();
      Student.prototype.sayScore = function () {
        console.log('Hi I score ' + this.score + ' I am ' + this.name);
      }
      // 实现个体不同继承
      var yejianxin = new Student('叶建新', 18, '男', 89);
      yejianxin.sayHi();
      yejianxin.sayScore();
      console.log(yejianxin.age);
    </script>
  </body>
</html>
